<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>KKTOKEN</title>
    <link rel="stylesheet" type="text/css" href="css/normalize.css"/>
    <link rel="stylesheet" type="text/css" href="css/home.css"/>
    <link rel="stylesheet" type="text/css" href="css/index1.css"/>

</head>

<body>
<div class="wrap">
    <div class="container">
        <!--导航栏-->
        <header>
            <div class="content">
                <a href="/index.html" class="headerLogo">
                    <img class="logoimg" src="img/logo.png" alt="logo"/>
                    <img class="logofont" src="img/font_logo.png" alt="logofont"/>
                </a>
                <ul class="headerNav">
                    <!--<li class="active" style="opacity: 1.0;">-->
                    <!--<div class="homeOption">自选</div>-->
                    <!--<div class="optional">-->

                    <!--</div>-->
                    <!--</li>-->
                    <li class="active">
                        <div class="homeVol">市值</div>
                    </li>
                    <li class="active jys" style="position: relative;">
                        <div class="jys_name">交易所</div>
                        <div class="bourse">
                            <ul style="color: #000;">
                            </ul>
                            <span class="jys_arro"></span>
                        </div>
                    </li>
                </ul>
                <div class="headerAdv">
                    <img src="img/home_ad_img.jpg" alt="navAdv"/>
                </div>
            </div>
        </header>
        <!--内容区-->
        <section>
            <div class="content center" style="background:initial">
                <!--内容区，左大块列表-->
                <div class="left_box"
                     style="width: 860px; height: auto;min-height:750px;background-color: inherit;float: left;">
                    <div class="left_content" style="float: none;">

                        <div class="list_header">
                            <div style="height: 30px;margin: 18px 5px 17px 0;">
                                <div class="list_search">
                                    <input class="search_ipt" type="text" placeholder="请输入关键词过滤" id="search"/>
                                    <span class="search_btn" onclick="toSearch()">
											<img src="img/nav_search@2x.png"/>
										</span>
                                </div>
                            </div>

                            <div class="list_title">
                                <span class="sort">#</span>
                                <span class="name">名称</span>
                                <span class="price">价格</span>
                                <span class="risefall">涨跌</span>
                                <span class="turnval">成交额(24h)</span>
                                <span class="freeval">流通市值</span>
                                <span class="trend">价格趋势(7d)</span>
                            </div>
                        </div>

                        <ul class="list_content" id="vollistPad">
                            <!--列表加载-->
                        </ul>
                    </div>
                    <div class="" style="width: 840px; height: 34px;">
                        <div class="pageList" id="pageList">
                        </div>
                    </div>

                </div>

                <div class="right_content">
                    <div class="right_top">
                        <p>
                            <a href="html/notice.html" >交易所公告</a>
                            <a href="html/notice.html" class="more_btn"></a>
                        </p>
                        <div class="listBox" id="artList" style="width: 100%;height: 368px;overflow: hidden;">
                            <ul id="no1" class="notice_list"></ul>
                        </div>
                    </div>

                    <div class="right_bottom">
                        <p><span id="riseBtn" class="rise selected">涨幅榜</span><span id="fallBtn" class="fall">跌幅榜</span>
                            <a href="html/chg_rise.html" class="more_btn"></a>
                        </p>

                        <div class="range_pad">
                            <p class="range_notice">24小时涨幅超过500万</p>
                            <ul class="range_title">
                                <li class="btc_rank" style="color: #000000;">排行</li>
                                <li class="btc_sort">名称</li>
                                <li class="btc_value">价格</li>
                                <li class="btc_percent">涨幅</li>
                            </ul>
                            <div class="tab_content">
                                <ul id="changesPad" class="rise_range_lists" style="min-height: 10px;">

                                </ul>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!--尾部-->
        <footer>
            <div class="content">
                <p class="copyright">copyright © 2018 KKTOKEN，粤ICP备17140751号-1·Powered By Weilaicaij</p>
                <ul class="linksTo">
                    <li>友情链接:</li>
                    <li>
                        <a href="http://www.8btc.com/" target="_blank">巴比特</a>
                    </li>
                    <li>
                        <a href="http://www.jinse.com/" target="_blank">金色财经</a>
                    </li>
                    <li>
                        <a href="https://www.btc123.com/" target="_blank">BTC123</a>
                    </li>
                    <li>
                        <a href="http://chainb.com/" target="_blank">铅笔</a>
                    </li>
                    <li>
                        <a href="https://www.coindesk.com/" target="_blank">coindesk</a>
                    </li>
                    <li>
                        <a href="http://www.qukuaiwang.com.cn/" target="_blank">区块链导航</a>
                    </li>
                    <li>
                        <a href="http://www.qukuaiwang.com.cn/" target="_blank">区块链</a>
                    </li>
                    <li>
                        <a href="https://www.7234.cn/" target="_blank">链世界</a>
                    </li>
                    <li>
                        <a href="https://www.feixiaohao.com/" target="_blank">非小号</a>
                    </li>
                    <li>
                        <a href="https://www.binance.com/" target="_blank">币安</a>
                    </li>
                    <li>
                        <a href="https://www.coingogo.com/" target="_blank">币源社区</a>
                    </li>
                    <li>
                        <a href="http://bitkan.com/" target="_blank">币看</a>
                    </li>
                    <li>
                        <a href="https://www.coolcoin.com/" target="_blank">酷币</a>
                    </li>
                    <li>
                        <a href="https://www.btc98.com/" target="_blank">比特酒吧</a>
                    </li>
                    <li>
                        <a href="http://sl.vc/" target="_blank">共享财经</a>
                    </li>
                    <li>
                        <a href="http://www.chainfor.com/" target="_blank">链向财经</a>
                    </li>
                    <li>
                        <a href="http://jgy.com/" target="_blank">九个亿财经</a>
                    </li>
                </ul>
            </div>
        </footer>

    </div>
</div>
</body>
<script src="js/jquery-2.1.1.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.pagination.js" type="text/javascript" charset="utf-8"></script>
<script src="js/index.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
  var urlhead = 'http://api.btcdata.top/api/api_kktoken';

  //当前交易所id
  var exchangeId = GetUrlParam("id"),
    //当前页的页数
    current = GetUrlParam("current") == "" ? 1 : GetUrlParam("current"),
    //页数
    showData = 1,
    coin_name = GetUrlParam("coin_name");

  $("#search").val(coin_name);
  $(function () {
    ajaxData();

    getExchange();

    if (exchangeId == "") {
      ajaxVolData()
    } else {
      ajaxExchangeData()
    }
  });

  if (exchangeId == "") {
    $(".active:eq(0)").css("opacity", "1")
  } else {
    $(".active:eq(1)").css("opacity", "1")
  }

  //		渲染后代理处理
  $("#swiperDiv .swiper-wrapper").on("click", ".swiper-slide", function () {
    exchangeId = $(this).attr("data-id");
    $('#vollistPad').empty();
    ajaxExchangeData(exchangeId);
  });

  //		交易所列表		点击Nav获取exchangeID加载对应页面
  function ajaxExchangeData() {
    $.get(urlhead + '/exchange_coin_info_lists/' + exchangeId + '?page_size=50&per_page=' + current + "&coin_name=" + coin_name, function (exchData) {
      showData = Math.ceil(exchData.data.total / 50);
      //           		分頁器設置
      $('#pageList').pagination({
        mode: 'fixed',
        pageCount: showData, //总页数,默认为9
        current: current, //当前第几页
        totalData: 200,
        callback: function (page_index) {
          window.location.href = "/index.html?id=" + exchangeId + "&current=" + page_index + "&coin_name=" + coin_name;
        },
      });
      //				导航栏内容置换
      $(".list_title .name").text("交易对");
      $(".list_title .price").text("最新价");
      $(".list_title .risefall").text("涨跌(24h)");
      $(".list_title .turnval").text("成交额(24h)");
      $(".list_title .freeval").text("24小时最高");
      $(".list_title .trend").text("24小时最低");
      $(".list_content .list_data .list_line li").css("margin-right", "12px");

      //				判斷獲取參數條目,
      var exchNum = exchData.data.total;
      if (exchNum > 50) {
        exchNum = 50;
      } else if (exchNum == 0 || exchNum == null) {

      }
      //				遍历生成
      for (var i = 0; i < exchNum; i++) {
        var exchImg = exchData.data.lists[i].icon_url,
          exchNam = exchData.data.lists[i].transaction_name,
          exchRmb = (exchData.data.lists[i].price),
          exchPrc = (exchData.data.lists[i].new_price),
          exchPer = exchData.data.lists[i].change,
          exchVol = exchData.data.lists[i].volume_of_business,
          exchHigh = exchData.data.lists[i].high,
          exchLow = exchData.data.lists[i].low,
          exchange_id = exchData.data.lists[i].exchange_id,
          coin_id = exchData.data.lists[i].coin_id
        //					if(exchImg=""||exchImg=null){}
        //					价格参数处理
        if (exchRmb >= 1) {
          if ((exchRmb.split(".")[0].length) > 8 || (exchRmb.split(".")[0].length) == 8) {
            exchRmb = changeTwoDecimal(exchRmb * 0.00000001) + "亿";
          } else if ((exchRmb.split(".")[0].length) > 4 || (exchRmb.split(".")[0].length) == 4) {
            exchRmb = changeTwoDecimal(exchRmb * 0.0001) + "万";
          } else {
            exchRmb = changeTwoDecimal(exchRmb);
          }

        } else if (exchRmb > 0 && exchRmb < 1) {
          exchRmb = parseFloat(exchRmb).toPrecision(3);
        }

        //					最新价参数处理
        if (exchPrc != "") {
          if (exchPrc >= 1) {
            exchPrc = changeTwoDecimal(exchPrc);
          } else if (exchPrc > 0 && exchPrc < 1) {
            exchPrc = parseFloat(exchPrc).toPrecision(3);
          }

          if ((exchPrc.split(".")[0].length) > 8 || (exchPrc.split(".")[0].length) == 8) {
            exchPrc = changeTwoDecimal(exchPrc * 0.00000001) + "亿";
          } else if ((exchPrc.split(".")[0].length) > 4 || (exchPrc.split(".")[0].length) == 4) {
            exchPrc = changeTwoDecimal(exchPrc * 0.0001) + "万";
          } else {
            exchPrc = changeTwoDecimal(exchPrc);
          }
          exchPrc = "/" + "￥" + exchPrc
        }

        //					涨幅百分比参数处理
        exchPer = changeTwoDecimal(exchPer);

        if ((exchVol.split(".")[0].length) > 8 || (exchVol.split(".")[0].length) == 8) {
          exchVol = changeTwoDecimal(exchVol * 0.00000001) + "亿";
        } else if ((exchVol.split(".")[0].length) > 4 || (exchVol.split(".")[0].length) == 4) {
          exchVol = changeTwoDecimal(exchVol * 0.0001) + "万";
        } else {
          exchVol = changeTwoDecimal(exchVol);
        }

        //					最高价参数处理
        if (exchHigh >= 1) {
          if ((exchHigh.split(".")[0].length) > 8 || (exchHigh.split(".")[0].length) == 8) {
            exchHigh = changeTwoDecimal(exchHigh * 0.00000001) + "亿";
          } else if ((exchHigh.split(".")[0].length) > 4 || (exchHigh.split(".")[0].length) == 4) {
            exchHigh = changeTwoDecimal(exchHigh * 0.0001) + "万";
          } else {
            exchHigh = changeTwoDecimal(exchHigh);
          }
        } else if (exchLow > 0 && exchLow < 1) {
          exchHigh = (+exchHigh).toFixed(7);
        }

        //					最低价参数处理
        if (exchLow >= 1) {
          if ((exchLow.split(".")[0].length) > 8 || (exchLow.split(".")[0].length) == 8) {
            exchLow = changeTwoDecimal(exchLow * 0.00000001) + "亿";
          } else if ((exchLow.split(".")[0].length) > 4 || (exchLow.split(".")[0].length) == 4) {
            exchLow = changeTwoDecimal(exchLow * 0.0001) + "万";
          } else {
            exchLow = changeTwoDecimal(exchLow);
          }
        } else if (exchLow > 0 && exchLow < 1) {
          exchLow = (+exchLow).toFixed(7);
        }

        exchHigh = parseFloat(exchHigh)
        exchLow = parseFloat(exchLow)

        //					生成交易所币种列表
        $('#vollistPad').append('<li class="list_data" onclick="toDetail(' + coin_id + ',' + exchange_id + ')">' +
          '<ul class="list_line">' +
          '<li class="sort">' + (((current - 1) * 50) + i + 1) + '</li>' +
          '<li class="name">' +
          '<span><img src="' + exchImg + '" class="btc_img"/></span>' +
          '<a href="###">' +
          '<span>' + exchNam + '</span>' +
          '</a>' +
          '</li>' +
          '<li class="price">' + exchRmb + exchPrc + '</li>' +
          '<li class="risefall">' + exchPer + '%</li>' +
          '<li class="turnval">￥' + exchVol + '</li>' +
          '<li class="freeval">' + exchHigh + '</li>' +
          '<li class="trend" style="margin-right: 10px;">' + exchLow +
          '</li>' +
          '</ul>' +
          '</li>');

        if (exchPer > 0 || exchPer == 0) {
          $("#vollistPad>.list_data>.list_line>.risefall:eq(" + i + ")").css("color", "#24AB00");
        } else if (exchPer < 0) {
          $("#vollistPad>.list_data>.list_line>.risefall:eq(" + i + ")").css("color", "#F41919");
        }
      }
    }, 'json')
  }


  //		左侧市值表 ，	加载涨跌数据后循环列表100条;
  function ajaxVolData() {

    $(".list_title .name").text("名称");
    $(".list_title .price").text("最新价");
    $(".list_title .risefall").text("涨跌(24h)");
    $(".list_title .turnval").text("成交额(24h)");
    $(".list_title .freeval").text("流通市值");
    $(".list_title .trend").text("走势图(24h)");
    $(".list_title .list_data .list_line li").css("margin-right", "12px")
    $.get(urlhead + '/coinmarketcap_lists?page_size=50&per_page=' + current + "&coin_name=" + coin_name, function (volData) {

      showData = Math.ceil(volData.data.total / 50);
      setarr(volData.data.lists);

      //     		分頁器設置
      $('#pageList').pagination({
        mode: 'fixed',
        pageCount: showData, //总页数,默认为9
        current: current, //当前第几页
        totalData: 200,
        callback: function (page_index) {
          window.location.href = "/index.html?id=" + exchangeId + "&current=" + page_index + "&coin_name=" + coin_name;
        }
      });

      var num = volData.data.total;
      if (num > 50) {
        num = 50;
      }

      for (var i = 0; i < num; i++) {
        var volImg = volData.data.lists[i].icon_url,
          volSyb = volData.data.lists[i].coin_symbol,
          volNam = volData.data.lists[i].name,
          volNamCn = volData.data.lists[i].chinese_name,
          volRmb = volData.data.lists[i].price_cny,
          volPer = volData.data.lists[i].percent_change24h,
          volSum = volData.data.lists[i].volume_cny,
          volSup = volData.data.lists[i].market_cap_cny,
          volChart = volData.data.lists[i].line_chart,
          id = volData.data.lists[i].id,
          arr = volData.data.lists[i].arr,
          chartsArr = volChart.split(" ")

        if ((volImg == "") || (volImg == "null")) {
          volImg = "img/home_coin@2x.png";
        }

//        if ((volRmb.split(".")[0].length) > 5 || (volRmb.split(".")[0].length) == 5) {
//          volRmb = changeTwoDecimal(volRmb * 0.0001) + "万";
//        } else {
//          volRmb = changeTwoDecimal(volRmb);
//        }
//
//        if (volPer > 1) {
//          volPer = changeTwoDecimal(volPer);
//        } else if (volPer < 0) {
//          volPer = Math.abs(volPer);
//          volPer = "-" + changeTwoDecimal(volPer);
//        }

        volPer = parseFloat(volPer);

        var a_point_0 = volChart.split(" ")[0];
        a_point_lenth = volChart.split(".")[0].length;
        b_point_lenth = volChart.split(".")[1].length;

        //					成交额
        if ((volSum.split(".")[0].length) > 9 || (volSum.split(".")[0].length) == 9) {
          volSum = changeTwoDecimal(volSum * 0.00000001) + "亿";
        } else if ((volSum.split(".")[0].length) > 5 || (volSum.split(".")[0].length) == 5) {
          volSum = changeTwoDecimal(volSum * 0.0001) + "万";
        } else {
          volSum = changeTwoDecimal(volSum);
        }

        if ((volSup.split(".")[0].length) > 9 || (volSup.split(".")[0].length) == 9) {
          volSup = changeTwoDecimal(volSup * 0.00000001) + "亿";
        } else if ((volSup.split(".")[0].length) > 5 || (volSup.split(".")[0].length) == 5) {
          volSup = changeTwoDecimal(volSup * 0.0001) + "万";
        } else {
          volSup = changeTwoDecimal(volSup);
        }

        var volChangeData
        $('#vollistPad').append('<li class="list_data" onclick="toDetail(' + id + ',\'\')">' +
          '<ul class="list_line">' +
          '<li class="sort">' + (((current - 1) * 50) + i + 1) + '</li>' +
          '<li class="name">' +
          '<span><img src="' + volImg + '" class="btc_img"/></span>' +
          '<a href="###">' +
          '<span>' + volSyb + ( volNamCn == '' ? '' : '-' + volNamCn ) + '</span>' +
          '</a>' +
          '</li>' +
          '<li class="price">￥' + volRmb + '</li>' +
          '<li class="risefall">' + volPer + '%</li>' +
          '<li class="turnval">￥' + volSum + '</li>' +
          '<li class="freeval">' + (volSup == 0 ? '-' : '￥' + volSup) + '</li>' +
          '<li class="trend" style="margin-right: 10px;">' +
          '<svg class="peity" height="25" width="100">' +
          '<polyline fill="none" points="' + arr + '" stroke="#3499da" stroke-width="2" stroke-linecap="square"></polyline>' +
          '</svg>' +
          '</li>' +
          '</ul>' +
          '</li>');

        if (volPer > 0 || volPer == 0) {
          $("#vollistPad>.list_data>.list_line>.risefall:eq(" + i + ")").css("color", "#24AB00");
        } else if (volPer < 0) {
          $("#vollistPad>.list_data>.list_line>.risefall:eq(" + i + ")").css("color", "#F41919");
        }
      }

    }, 'json');
  }


  //右侧公告
  $.get(urlhead + '/notice?page_size=20', function (res) {
    var num = 20;
    for (var a = 0; a < 2; a++) {
      for (var i = 0; i < num; i++) {
        var homeurls = res.data.lists[i].title_url,
          hometitle = res.data.lists[i].title_content_translate == "" ? res.data.lists[i].title_content_customary : res.data.lists[i].title_content_translate,
          hometime = res.data.lists[i].title_time
        hometime = hometime.slice(6, 16);
        if(hometitle != ""){
          $('#no1').append('<li class="list_item"><a href="' + homeurls + '" target="_blank" title="' + hometitle + '">' +
            '<span class="news_title">' + hometitle + '</span>' +
            '<span class="news_time">' + hometime + '</span></a></li>');
        }
      }
    }
  }, 'json');

  //点击事件切换涨跌幅视图
  //预先默认涨幅表为涨幅显示
  var changes = "performer";

  $("#riseBtn").click(function () {
    changes = 'performer';
    $("#changesPad").empty();
    ajaxData(changes);
    $(this).addClass("selected");
    $("#fallBtn").removeClass("selected");
  })

  $("#fallBtn").click(function () {
    changes = 'drop';
    $("#changesPad").empty();
    ajaxData(changes);
    $(this).addClass("selected");
    $("#riseBtn").removeClass("selected");

  })

  //		涨跌幅列表
  function ajaxData() {
    //$('.rise_range_lists').empty();
    $.get(urlhead + '/' + changes + '?page_size=20', function (rangedata) {
      //生成列表
      var rangenum = rangedata.data.total;
      if (rangenum > 20) {
        rangenum = 20;
      }

      //				var rangenum = 20;
      for (var i = 0; i < rangenum; i++) {
        var rangeName = rangedata.data.lists[i].coin_symbol;
        var rangeImg = rangedata.data.lists[i].icon_url;
        var rangeVal = changeTwoDecimal(rangedata.data.lists[i].price_cny);
        var rangePer = rangedata.data.lists[i].percent_change24h;
        var id = rangedata.data.lists[i].id;
        if (rangePer > 0) {
          rangePer = "+" + changeTwoDecimal(rangePer) + "%"
        } else {
          rangePer = changeTwoDecimal(rangePer) + "%";
        }
        ;
        if (rangeImg == "" || rangeImg == null) {
          rangeImg = "img/home_coin@2x.png"
        }
        var ranges = (i + 1)

        $('.rise_range_lists').append('<li class="range_line" onclick="toDetail(' + id + ',\'\')">' +
          '<ul>' +
          '<li class="btc_rank rank_x" id="r_' + ranges + '">' + ranges + '</li>' +
          '<li class="btc_sort">' +
          '<img class="btc_icon" src=' + rangeImg + ' />' +
          '<span id="btc_name">' + rangeName + '</span>' +
          '</li>' +
          '<li class="btc_value">￥' + rangeVal + '</li>' +
          '<li class="btc_percent percent_rise">' + rangePer + '</li>' +
          '</ul>' +
          '</li>');

        //			判斷前三名排序
        if (ranges == 1) {
          $("#r_1").addClass("rank1").removeClass("rank_x");
        } else if (ranges == 2) {
          $("#r_2").addClass("rank2").removeClass("rank_x");
        } else if (ranges == 3) {
          $("#r_3").addClass("rank3").removeClass("rank_x");
        }

        //			判断涨跌,更改颜色
        if (changes == "drop") {
          $("#changesPad .range_line .btc_percent").removeClass("percent_fall");
          $("#changesPad .range_line .btc_percent").addClass("percent_rise")
        } else {
          $("#changesPad .range_line .btc_percent").removeClass("percent_rise");
          $("#changesPad .range_line .btc_percent").addClass("percent_fall")
        }
      }
      ;
    }, 'json');

  }

  //			列表前往详情页
  //  $(".list_data").click(function () {
  //			window.open("html/detail.html");
  //			window.location.href = "html/detail.html"
  //  });
  //			最新公告滚动
  var mun = 0;
  var scroll1 = null;

  function scroll() {

    scroll1 = setInterval(function () {
      mun--;
      $('#no1').eq(0).css('margin-top', mun + 'px');
      if (mun == -(35 * 20)) {
        $('#no1').css('margin-top', '0')
        setTimeout(function () {
          mun = 0;
          clearInterval(scroll1);
          scroll()
        }, 80)
      }
    }, 50)
  }

  scroll();

  //鼠标事件,移入滚动暂停
  $('.notice_list').mouseover(function () {
    clearInterval(scroll1);
    $(this).css("color", "blue !important");
  });

  //鼠标事件,移出滚动继续
  $('.notice_list').mouseout(function () {
    scroll()
  })

  //导航栏鼠標移動時效果
  $(".homeVol").click(function () {
    $(this).css("opacity", "1").siblings().css("opacity", "0.5");
    $('#vollistPad').empty();
    ajaxVolData()
  })


  $(".bourse ui li").click(function (index) {
    var index = $(this).index();
  })

  function setarr(datalist) {
    var tiem = 100 / 24;
    for (let x of datalist) {
      var s = [];
      var timearr = [];
      var h = 0;
      var closeMin = 9999999999;
      var closeMax = 0;
      var arr = x.line_chart.split(" ");
      for (let n of arr) {
        if (Number(n) < Number(closeMin)) closeMin = n;
        if (Number(n) > Number(closeMax)) closeMax = n;
      }
      for (let n of arr) {
        s.push(100 - h);
        if (closeMax == closeMin) {
          s.push(12);
        } else {
          s.push(24 - ( n - closeMin) * (24 / (closeMax - closeMin)));
        }
        h += tiem;
      }
      x.arr = s.join(" ");
    }
    return datalist;
  }

  function toSearch() {
    window.location.href = "/index.html?id=" + exchangeId + "&current=" + 1 + "&coin_name=" + $("#search").val();
  }

  $('.search_ipt').on('keypress', function (event) {
    if (event.keyCode == 13) {
      toSearch();
    }
  });
</script>
</html>